The Audio Mixer


The Windows Audio Mixer

The mixer controls the routing of audio lines to a device for playing or recording.
  1. A computer running Microsoft Windows can have zero, one or more audio mixer devices
  2. Each audio mixer device may have one or more destination audio lines
  3. Each destination audio line may have zero, one or more source audio lines
  4. Each audio line (destination or source) may have zero, one or more mixer controls.

La mezcladora controla el ruteo de líneas de audio a un dispositivo para reproducción o grabación.
  1. Una computadora con Microsoft Windows puede tener cero, uno, o más dispositivos mezcladores de audio
  2. Cada dispositivo mezclador de audio puede tener una o más líneas de audio de destino
  3. Cada línea de audio de destino puede tener cero, uno o más líneas de audio fuente

Problem 1
Create a Dialog application called MixerInfo using Wintempla to test the audio mixer in Microsoft Windows. After creating the project, edit the stdafx.h file to include the header files for multimedia (the ADC and the DAC). Then, insert a list view control to display the mixer devices.
Cree una aplicación de diálogo llamada MixerInfo usando Wintempla para probar la mezcladora de audio en Microsoft Windows. Después de crear el proyecto, edite el archivo stdafx.h para incluir los archivos de encabezado para multimedia (el ADC y el DAC). Entonces, inserte un control de list view para mostrar los dispositivos de la mezcladora.

MixerInfoRun

stdafx.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
. . .
#define WIN_DAC_ADC_SUPPORT
. . .


MixerInfo.cpp
. . .
void MixerInfo::Window_Open(Win::Event& e)
{
     //_______________________________________________________________________ 1. lvDevice
     lvDevice.Cols.Add(0, LVCFMT_LEFT, 250, L"Mixer");
     lvDevice.Cols.Add(1, LVCFMT_LEFT, 120, L"Mixer Line");
     lvDevice.Cols.Add(2, LVCFMT_LEFT, 45, L"#ctrl");
     lvDevice.Cols.Add(3, LVCFMT_LEFT, 220, L"Component Type");
     lvDevice.Cols.Add(4, LVCFMT_LEFT, 90, L"Ctrl Name");
     lvDevice.Cols.Add(5, LVCFMT_RIGHT, 60, L"Ctrl ID");
     lvDevice.Cols.Add(6, LVCFMT_RIGHT, 40, L"Min");
     lvDevice.Cols.Add(7, LVCFMT_RIGHT, 80, L"Max");
     lvDevice.Cols.Add(8, LVCFMT_RIGHT, 80, L"Value");
     //_______________________________________________________________________ 2. Variable
     const DWORD numMixers = ::mixerGetNumDevs();
     DWORD mixerIndex, destination, control;
     MMRESULT mmr = 0;
     HMIXER mixer = 0;
     MIXERCAPS mixerCaps;
     MIXERLINE mixerLine;
     MIXERLINECONTROLS mxlc;
     MIXERCONTROL mxc[32];
     MIXERCONTROLDETAILS mxcd;
     MIXERCONTROLDETAILS_UNSIGNED mxcdVol;
     mixerLine.cbStruct = sizeof(MIXERLINE);
     int i = 0;
     wchar_t text[64];
     for (mixerIndex = 0; mixerIndex < numMixers; mixerIndex++)
     {
          //______________________________________________________________________ 3. For each device
          mmr = ::mixerGetDevCaps(mixerIndex, &mixerCaps, sizeof (MIXERCAPS));
          if (mmr != MMSYSERR_NOERROR)
          {
               this->MessageBox(Mm::Assistant::GetErrorText(mmr), L"mixerGetDevCaps", MB_OK | MB_ICONERROR);
               return;
          }
          //____________________________________________________________________ 4. For each destination
          for (destination = 0; destination < mixerCaps.cDestinations; destination++)
          {
               memset(&mixerLine, 0, sizeof(MIXERLINE));
               mixerLine.cbStruct = sizeof(MIXERLINE);
               mixerLine.dwDestination = destination;
               mixerLine.dwSource = -1;
               //mmr = ::mixerGetLineInfo((HMIXEROBJ)(UINT_PTR)mixerIndex, &mixerLine, MIXER_OBJECTF_MIXER|MIXER_GETLINEINFOF_SOURCE);
               mmr = ::mixerGetLineInfo((HMIXEROBJ)(UINT_PTR)mixerIndex, &mixerLine, MIXER_OBJECTF_MIXER|MIXER_OBJECTF_MIXER|MIXER_GETLINEINFOF_DESTINATION);
               if (mmr != MMSYSERR_NOERROR)
               {
                    this->MessageBox(Mm::Assistant::GetErrorText(mmr), L"mixerGetLineInfo", MB_OK | MB_ICONERROR);
                    return;
               }
               mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
               mxlc.dwLineID = mixerLine.dwLineID;
               mxlc.cControls = mixerLine.cControls;
               mxlc.cbmxctrl = sizeof(MIXERCONTROL);
               mxlc.pamxctrl = mxc;
               mmr = ::mixerGetLineControls((HMIXEROBJ)(UINT_PTR)mixerIndex, &mxlc, MIXER_OBJECTF_MIXER | MIXER_GETLINECONTROLSF_ALL);
               if (mmr != MMSYSERR_NOERROR)
               {
                    this->MessageBox(Mm::Assistant::GetErrorText(mmr), L"mixerGetLineControls", MB_OK | MB_ICONERROR);
                    return;
               }
               mxcd.cChannels = 1;
               mxcd.cMultipleItems = 0;
               mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
               mxcd.paDetails = &mxcdVol;
               mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
               //_________________________________________________________________ 5. For each control
               for (control = 0; control < mixerLine.cControls; control++)
               {
                    lvDevice.AddItem(i, mixerCaps.szPname, 0, 0);
                    lvDevice.SetItemText(i, 1, mixerLine.szName);
                    _snwprintf_s(text, 64, _TRUNCATE, L"%u", mixerLine.cControls);
                    lvDevice.SetItemText(i, 2, text);
                    lvDevice.SetItemText(i, 3, Mm::Assistant::GetComponentTypeText(mixerLine.dwComponentType));
                    lvDevice.SetItemText(i, 4, mxc[control].szName);
                    _snwprintf_s(text, 64, _TRUNCATE, L"%u", mxc[control].dwControlID);
                    lvDevice.SetItemText(i, 5, text);
                    _snwprintf_s(text, 64, _TRUNCATE, L"%u", mxc[control].Bounds.dwMinimum);
                    lvDevice.SetItemText(i, 6, text);
                    _snwprintf_s(text, 64, _TRUNCATE, L"%u", mxc[control].Bounds.dwMaximum);
                    lvDevice.SetItemText(i, 7, text);
                    //_______________________________________________
                    mxcd.dwControlID = mxc[control].dwControlID;
                    mmr = ::mixerGetControlDetails((HMIXEROBJ)(UINT_PTR)mixerIndex, &mxcd, MIXER_GETCONTROLDETAILSF_VALUE);
                    if (mmr == MMSYSERR_NOERROR)
                    {
                         _snwprintf_s(text, 64, _TRUNCATE, L"%u", mxcdVol.dwValue);
                         lvDevice.SetItemText(i, 8, text);
                    }
               }
          }
     }
     //MIXERCONTROLDETAILS mxcd;
     //MIXERCONTROLDETAILS_UNSIGNED mxcdVol;
     //mxcd.cChannels = 1;
     //mxcd.cMultipleItems = 0;
     //mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
     //mxcd.paDetails = &mxcdVol;
     //mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
     //mxcd.dwControlID = controlID;
     //mxcdVol.dwValue = level;

     //MMRESULT mmr = ::mixerSetControlDetails((HMIXEROBJ)(UINT_PTR)mixerIndex, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
     //if (mmr != MMSYSERR_NOERROR) return Mm::Assistant::GetErrorText(mmr);
}

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home